package 南京理工大学;

import bean.ExBean;
import com.alibaba.excel.EasyExcel;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import utils.ExcelUtils;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class NJu {
    public static final String Urls = "http://202.119.85.163/open/";

    public static void main(String[] args) throws IOException {
        NJuBean nJuBean = null;
        ArrayList<NJuBean> nJuBeans = new ArrayList<>();
        String Url = "http://202.119.85.163/open/DsDir_View.aspx?yxsh=104";
        Connection connect = Jsoup.connect(Url);
        Document post = connect.post();
        Element element = post.getElementById("ctl00_contentParent_dgData_ctl03_dlistSd");
        for (Element a : element.getElementsByTag("a")) {
            nJuBean = new NJuBean();
//            System.out.println(a.text());
            nJuBean.setT_name(a.text());
            Connection connect1 = Jsoup.connect(Urls + a.attr("href"));
            Document post1 = connect1.post();
            nJuBean.setMsg(post1.getElementsByClass("tbline").text());
//            System.out.println(post1.getElementsByClass("tbline").text());
            nJuBeans.add(nJuBean);
        }
        EasyExcel.write("src/NJu.xlsx", NJuBean.class).sheet("user").doWrite(nJuBeans);

    }
}
